package buber.genetic;

import java.util.Iterator;

import buber.genetic.interfaces.Chromosome;
import buber.genetic.interfaces.Member;
import buber.genetic.interfaces.Score;


public class NumberOfOnes implements Score{

	public NumberOfOnes(){
		
	}
	public double getScore(Member m) {
		//System.out.println("[score]"+m.asString());
		int ONE=1;
		int score=0;
		for(Iterator<Chromosome> cit = m.getChromosomes().iterator();cit.hasNext();){
			Chromosome ch = cit.next();
			for(int i=0;i<ch.getSize();i++){
				if(ch.getGene(i)==ONE){
					score++;
				}
			}
		}
		return score;
	}
	public double getMaxScore(Member m) {
		
		return m.chSize()*m.getChromosomes().size();
	}
	public double getMinScore(Member m) {
		return 0;
	}
	public boolean isOptimal(Double current,Member m) {
		if(current==getMaxScore(m)){
			return true;
		}
		else{
			return false;
		}
	}

}
